package com.cius.ssm.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by ciuscheung on 17/4/13.
 */
@Controller
public class LoginController {

    //登录
    @RequestMapping("/login")
    public String login(HttpSession session,String name, String pass) throws Exception{
        //调用service进行身份认证

        //在session中保存用户身份信息
        session.setAttribute("username",name);
        return "redirect:/product/findAllProducts.action";
    }

    //登出
    @RequestMapping("/logout")
    public String logout(HttpSession session) throws Exception{

        //让session失效
        session.invalidate();
        //重定向到商品列表页面
        return "redirect:/product/findAllProducts.action";
    }
}
